/**
 * @Title: index
 * @Package mall-fe
 * @author Shinelon
 * @date 2029/9/6 18:54
 * @version V1.0
 * @desc 用户中心
 */
'use strict';
require('./index.css');
require('js/common/nav/index.js');
require('js/common/header/index.js');
var navSide         = require('js/common/nav-side/index.js');
var shiqla             = require('util/shiqlamall');
var userService           = require('service/user-service.js');
var templateIndex   = require('./template.string');

// page 逻辑部分
var page = {
    init: function(){
        this.onLoad();
    },
    onLoad : function(){
        // 初始化左侧菜单
        navSide.init({
            name: 'user-center'
        });
        // 加载用户信息
        this.loadUserInfo();
    },
    // 加载用户信息
    loadUserInfo : function(){
        var userHtml = '';
        userService.getUserInfo(function(res){
            userHtml = shiqla.renderHtml(templateIndex, res);
            $('.panel-body').html(userHtml);
        }, function(errMsg){
            window.location.href = './result.html?type=getUserInfo';
        });
    }
};
$(function(){
    page.init();
});